﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="hrPersonEntry.aspx.cs" Inherits="ZX.WebApp.EHR.hrPersonEntry" %>

<%@ Register Assembly="ZX.Web.UI.Controls" Namespace="ZX.Web.UI.Controls.UserControl"
    TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript">
        //获取url里的参数值 name:参数名称
        function getPar(source, name) {
            var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
            if (reg.test(source))
                return RegExp.$2;
            return "";
        };
        function getPar1(name) {
            var _url = "http://" + document.location;
            return getPar(_url, name);
        }

       //当部门发生变化时,获取该部门下所有岗位
        function ChangeDept() {
            var deptID = $("#SelectForDept").val();
            var url = "../Extend/AjaxData/jsonlist.aspx?entity=DatPost&condition=DeptID='" + deptID + "'";
            $.get(url, function (d, s) {
                var list = eval("(" + d + ")");
                if (list.total == 0) {
                    alert("该部门无岗位信息，请先维护该部门岗位信息！");
                    $("#position").find('option').remove();
                    //parent.closeWin();
                }
                else {
                    for (var o in list.rows) {
                        var v = list.rows[o].PostID;
                        var t = list.rows[o].PostName;
                        if (typeof (t) != "undefined") {
                            $("#position").append("<option value='" + v + "'>" + t + "</option>");
                            //document.getElementById("PositionID").options.add(new Option(t, v));
                        }
                    }
                }
            })
        }

        //数据保存
        function Save() {
            var positionId = $("#position").val(); //岗位
            if (positionId == "") {
                alert("岗位不能为空!");
                return;
            }
            //提交数据
            var deptId = $("#SelectForDept").val(); //部门
            var detailId = getPar1("detailId");
            if (detailId == "") {
                alert("获取DetailID失败！");
                return;
            }
            YAHOO.util.Connect.asyncRequest('POST', "hrAjax.aspx?flag=yingpinruzhi&deptId=" + deptId + "&positionId=" + positionId + "&detailId=" + detailId, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str.substring(0, 1) == "0") {
                            alert("入职成功!");
                            parent.closeWin();
                            parent.ReLoadData();
                        }
                        else {
                            if (str.substring(0, 2) == "e_") {
                                alert("入职失败:" + str);
                            }
                            else {
                                alert("入职失败,请检查!");
                            }
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
          <br />
    <table style="font-family: 宋体, Arial, Helvetica, sans-serif; font-size: small">
      <tr>
        <td>&nbsp;</td>
        <td> 
        请选择部门：
        </td> 
        <td>
            <cc1:DeptList ID="DeptList1" IsLoad="true" runat="server"></cc1:DeptList>
        </td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <tr>
        <td>&nbsp;</td>
        <td>请选择岗位：</td>
        <td><select id="position" style="width: 156px"></select></td>
      </tr>
    </table>     
    </div>
    </form>
</body>
</html>
